package com.AAA.controller.mht;

import com.AAA.entity.LayData;
import com.AAA.entity.MyPage;
import com.AAA.entity.mht.TMhtRecond;
import com.AAA.service.mht.ITmhtRecondService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("tmhtrecond")
public class TmhtRecondController {
    @Autowired
    private ITmhtRecondService service;

    @PostMapping("add")
    public LayData add(HttpServletRequest request){

            Integer id = Integer.valueOf(request.getParameter("id"));
            boolean byid = service.byid(id);
            if (byid){
                return new LayData(0);
            }else {
                boolean add = service.add(request);
                return new LayData(add);

            }
    }
@PostMapping("update")
public LayData updata(TMhtRecond tMhtRecond){

    return new LayData(service.edit(tMhtRecond));
}

    @RequestMapping("query")
    public LayData query(MyPage myPage,String rname,String pname){

        return new LayData(service.query(myPage,rname,pname));
    }

    @PostMapping("delete")
public LayData del(Integer id){
        return new LayData(service.del(id));
    }
}
